#include "test_dm.h"
#include "cm_uart.h"
#include "cm_demo_uart.h"



void cm_test_dm_operation(unsigned char*cmd[],int len)
{
    if(0 == strncmp("START",cmd[2],strlen("START")))
    {
        cm_demo_printf("cm_mobile_dm_start ret:%d\n",cm_mobile_dm_start());
    }else if(0 == strncmp("STOP",cmd[2],strlen("STOP")))
    {
        cm_demo_printf("cm_mobile_dm_stop ret:%d\n",cm_mobile_dm_stop());
    }
    else if(0 == strncmp("STATE",cmd[2],strlen("STATE")))
    {
        int32_t state = -1;
        cm_demo_printf("cm_mobile_dm_get_state ret:%d\n",cm_mobile_dm_get_state(&state));
        cm_demo_printf("get state:%d\n",state);
    }else if(0 == strncmp("SET_OPTION",cmd[2],strlen("SET_OPTION")))
    {
        char temp1[50] = "RTOS";
        char temp2[50] = "M100000052";
        char temp3[50] = "n525A97z0M7Vyh91b0508l7j0U5g2g9Y";
        char temp4[50] = "shipei.fxltsbl.com";
        char temp5[50] = "ML302";
        char temp6[50] = "DNLM";
        int  period    = 300;
        int  port	   = 5683;
        int  tmtype    = 1; //linux的SDK必须设置为1
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_OSVER, temp1, 50));
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_UPDATEPERIOD, &period, 6));
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_APPKEY, temp2, 50));
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_PASSWORD, temp3, 50));
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_TMLTYPE, &tmtype, 6));
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_URL, temp4, 50));
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_PORT, &port, 6));
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_SWNAME, temp5, 50));
        cm_demo_printf("cm_mobile_dm_set_option ret:%d\n",cm_mobile_dm_set_option(MOBILE_SWVER, temp6, 50));
    }else if(0 == strncmp("GET_OPTION",cmd[2],strlen("GET_OPTION")))
    {
        char temp[50] = {0};
        int get_temp2 = 0;
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_OSVER, temp, 50));
        cm_demo_printf("MOBILE_OSVER:%s\n",temp);
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_UPDATEPERIOD, &get_temp2, 6));
        cm_demo_printf("MOBILE_UPDATEPERIOD:%d\n",get_temp2);
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_APPKEY, temp, 50));
        cm_demo_printf("MOBILE_APPKEY:%s\n",temp);
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_PASSWORD, temp, 50));
        cm_demo_printf("MOBILE_PASSWORD:%s\n",temp);
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_TMLTYPE, &get_temp2, 6));
        cm_demo_printf("MOBILE_TMLTYPE:%d\n",get_temp2);
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_URL, temp, 50));
        cm_demo_printf("MOBILE_URL:%s\n",temp);
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_PORT, &get_temp2, 6));
        cm_demo_printf("MOBILE_PORT:%d\n",get_temp2);
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_SWNAME, temp, 50));
        cm_demo_printf("MOBILE_SWNAME:%s\n",temp);
        cm_demo_printf("DM get option ret: %d\n",cm_mobile_dm_get_option(MOBILE_SWVER, temp, 50));
        cm_demo_printf("MOBILE_SWVER:%s\n",temp);
    }
    else{
        cm_demo_printf("param error!\n");
    }
}

